package com.ioc.demo.controller;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.lang.Contract;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 王圆豪
 * Date: 2025-07-04
 * Time: 21:36
 */

@RequestMapping("/prop")
@RestController
@Component
public class PropertiesController {
    @Value("${my.key1}")
    private String myKey1;

    @Value("${my.key2}")
    private String myKey2;

    @RequestMapping("/read")
    public String readValue(){
        return "<h1>读取配置文件：" + myKey1 + "<h1>";
    }

    @PostConstruct
    public void init(){
        System.out.println("读取配置文件：" + myKey1);
        System.out.println("读取配置文件：" + myKey2);
    }
}
